import { type FC, type PropsWithChildren, useState } from 'react';
import { AudioChatContext } from '@/components/AudioChatProvider/context';
import type { IMessage } from '@/types';

export const AudioChatProvider: FC<PropsWithChildren> = ({ children }) => {
  const [wsConnected, setWsConnected] = useState(false);
  const [botSpeaking, setBotSpeaking] = useState(false);
  const [botAudioPlaying, setBotAudioPlaying] = useState(false);
  const [userSpeaking, setUserSpeaking] = useState(false);
  const [chatMessages, setChatMessages] = useState<IMessage[]>([]);
  return (
    <AudioChatContext.Provider
      value={{
        wsConnected,
        setWsConnected,
        botSpeaking,
        setBotSpeaking,
        botAudioPlaying,
        setBotAudioPlaying,
        userSpeaking,
        setUserSpeaking,
        chatMessages,
        setChatMessages,
      }}
    >
      {children}
    </AudioChatContext.Provider>
  );
};
